Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Miri on CI #578

Merged
merged 2 commits into from
Jan 7, 2022
Merged

Run Miri on CI #578

merged 2 commits into from
Jan 7, 2022

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Oct 9, 2020

No description provided.

@taiki-e taiki-e marked this pull request as draft October 9, 2020 13:45
@taiki-e taiki-e force-pushed the miri branch 3 times, most recently from df3d7ff to b8706fc Compare October 9, 2020 15:01
bors bot added a commit that referenced this pull request Oct 9, 2020
580: Fix UB in destroy_array test r=jeehoonkang a=taiki-e

Reportrd by Miri in #578 ([log](https://github.com/crossbeam-rs/crossbeam/runs/1232029543?check_suite_focus=true))

https://github.com/crossbeam-rs/crossbeam/blob/e08b21cc086fc42af0e9927a68bc3120bee87af5/crossbeam-epoch/src/collector.rs#L378-L388

`ptr` is a pointer to `Vec<i32>`, but deallocated as `Vec<u8>`.

Co-authored-by: Taiki Endo <[email protected]>
@taiki-e taiki-e force-pushed the miri branch 7 times, most recently from 5e489fc to 1739f79 Compare October 14, 2020 19:49
@taiki-e
Copy link
Member Author

taiki-e commented Oct 24, 2020

crossbeam-channel test takes about an hour, so I'll reduce iterations more... (other crates are okay)

@taiki-e taiki-e force-pushed the miri branch 3 times, most recently from 7abf8c5 to 57bc114 Compare November 3, 2020 13:16
@taiki-e taiki-e changed the title [wip] Run Miri on CI Run Miri on CI Nov 3, 2020
@taiki-e taiki-e force-pushed the miri branch 3 times, most recently from 8379c10 to f1c884d Compare November 3, 2020 16:13
@taiki-e taiki-e force-pushed the miri branch 3 times, most recently from 2e206c4 to 1251582 Compare November 16, 2020 22:51
@taiki-e taiki-e marked this pull request as ready for review November 16, 2020 22:53
@taiki-e taiki-e added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author label Nov 29, 2020
@taiki-e
Copy link
Member Author

taiki-e commented Feb 15, 2021

It seems some tests hang when using the latest Miri.

@taiki-e taiki-e added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author label Feb 15, 2021
@RalfJung
Copy link
Contributor

Interesting, maybe something in crossbeam changed and now it's running into rust-lang/miri#1388?

@taiki-e
Copy link
Member Author

taiki-e commented Feb 19, 2021

I'm not sure. Most of the commits after January 1st were written by me, but I don't think there were relevant changes for the crossbeam-deque that hang occurred.

@taiki-e
Copy link
Member Author

taiki-e commented Feb 19, 2021

I guess it's related to rust-lang/miri#1686, but currently I don't have the bandwidth to investigate it.

@RalfJung
Copy link
Contributor

RalfJung commented Feb 19, 2021

Good point. You could run Miri with -Zmiri-compare-exchange-weak-failure-rate=0.0 to check this.

@taiki-e
Copy link
Member Author

taiki-e commented Feb 19, 2021

@RalfJung Thanks. I'll try it.

@taiki-e
Copy link
Member Author

taiki-e commented Feb 20, 2021

Hmm, it seems -Zmiri-compare-exchange-weak-failure-rate=0.0 doesn't fix hang. https://github.com/crossbeam-rs/crossbeam/pull/578/checks?check_run_id=1940042095

Currently, miri is unavailable on the latest nightly, so I'll try again once rust-lang/rust#82253 is merged.

@taiki-e taiki-e removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author label Jan 7, 2022
@taiki-e taiki-e marked this pull request as ready for review January 7, 2022 12:05
bors bot added a commit that referenced this pull request Jan 7, 2022
763: Use Box::into_raw instead of mem::forget-in-disguise r=taiki-e a=taiki-e

This fixes the following stacked borrows violation.

```sh
MIRIFLAGS="-Zmiri-tag-raw-pointers" cargo miri test -p crossbeam-queue
```

```text
error: Undefined Behavior: trying to reborrow for Unique at alloc67500, but parent tag <180167> does not have an appropriate item in the borrow stack
   --> /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/slice/raw.rs:130:14
    |
130 |     unsafe { &mut *ptr::slice_from_raw_parts_mut(data, len) }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to reborrow for Unique at alloc67500, but parent tag <180167> does not have an appropriate item in the borrow stack
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
            
    = note: inside `std::slice::from_raw_parts_mut::<crossbeam_queue::array_queue::Slot<i32>>` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/slice/raw.rs:130:14
    = note: inside `<crossbeam_queue::ArrayQueue<i32> as std::ops::Drop>::drop` at /Users/taiki/projects/crossbeam/crossbeam-queue/src/array_queue.rs:424:23
    = note: inside `std::ptr::drop_in_place::<crossbeam_queue::ArrayQueue<i32>> - shim(Some(crossbeam_queue::ArrayQueue<i32>))` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:188:1
note: inside `capacity` at crossbeam-queue/tests/array_queue.rs:24:5
   --> crossbeam-queue/tests/array_queue.rs:24:5
    |
24  |     }
    |     ^
note: inside closure at crossbeam-queue/tests/array_queue.rs:20:1
   --> crossbeam-queue/tests/array_queue.rs:20:1
    |
19  |   #[test]
    |   ------- in this procedural macro expansion
20  | / fn capacity() {
21  | |     for i in 1..10 {
22  | |         let q = ArrayQueue::<i32>::new(i);
23  | |         assert_eq!(q.capacity(), i);
24  | |     }
25  | | }
    | |_^
    = note: inside `<[closure@crossbeam-queue/tests/array_queue.rs:20:1: 25:2] as std::ops::FnOnce<()>>::call_once - shim` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `test::__rust_begin_short_backtrace::<fn()>` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/test/src/lib.rs:575:5
    = note: inside closure at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/test/src/lib.rs:566:30
    = note: inside `<[closure@test::run_test::{closure#1}] as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send> as std::ops::FnOnce<()>>::call_once` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1854:9
    = note: inside `<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>> as std::ops::FnOnce<()>>::call_once` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:271:9
    = note: inside `std::panicking::r#try::do_call::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/panicking.rs:406:40
    = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>>` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/panicking.rs:370:19
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/panic.rs:133:14
    = note: inside `test::run_test_in_process` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/test/src/lib.rs:598:18
    = note: inside closure at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/test/src/lib.rs:492:39
    = note: inside `test::run_test::run_test_inner` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/test/src/lib.rs:530:13
    = note: inside `test::run_test` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/test/src/lib.rs:562:28
    = note: inside `test::run_tests::<[closure@test::run_tests_console::{closure#2}]>` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/test/src/lib.rs:305:17
    = note: inside `test::run_tests_console` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/test/src/console.rs:290:5
    = note: inside `test::test_main` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/test/src/lib.rs:116:15
    = note: inside `test::test_main_static` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/test/src/lib.rs:135:5
    = note: inside `main`
    = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:123:18
    = note: inside closure at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/rt.rs:145:18
    = note: inside `std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:259:13
    = note: inside `std::panicking::r#try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/panicking.rs:406:40
    = note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/panicking.rs:370:19
    = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/panic.rs:133:14
    = note: inside closure at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/rt.rs:128:48
    = note: inside `std::panicking::r#try::do_call::<[closure@std::rt::lang_start_internal::{closure#2}], isize>` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/panicking.rs:406:40
    = note: inside `std::panicking::r#try::<isize, [closure@std::rt::lang_start_internal::{closure#2}]>` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/panicking.rs:370:19
    = note: inside `std::panic::catch_unwind::<[closure@std::rt::lang_start_internal::{closure#2}], isize>` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/panic.rs:133:14
    = note: inside `std::rt::lang_start_internal` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/rt.rs:128:20
    = note: inside `std::rt::lang_start::<()>` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/rt.rs:144:17
    = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
```

cc #578

Co-authored-by: Taiki Endo <[email protected]>
@taiki-e
Copy link
Member Author

taiki-e commented Jan 7, 2022

bors r+

@bors
Copy link
Contributor

bors bot commented Jan 7, 2022

Build succeeded:

@bors bors bot merged commit 858bc6e into master Jan 7, 2022
@bors bors bot deleted the miri branch January 7, 2022 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants